package yja.gzw.app.fragmentview

import android.widget.Toast
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import yja.gzw.app.R
import yja.gzw.app.adapter.FabuddAdapter
import yja.gzw.app.adapter.ZhuanquAdapter
import yja.gzw.app.base.BaseFragment
import yja.gzw.app.databinding.FragmentFabuddBinding
import yja.gzw.app.model.UserData
import yja.gzw.app.viewmodel.Mainviewmodel

class FabuddFragment :BaseFragment<Mainviewmodel, FragmentFabuddBinding>(R.layout.fragment_fabudd){

    private lateinit var fabiada: FabuddAdapter

    override fun initView() {
        //todo 这里的id 需要通过数据库来获取自己的id
        viewmodel.onfabudingdanddwang(UserData.token,mapOf("page" to "1","pagesize" to "10","user_id" to ""))


    }

    override fun dataObservese() {

        viewmodel.onfabudingdandd.observe(this, Observer {
            if(it.code==1){

                binding.review.layoutManager=
                    LinearLayoutManager(context)
                fabiada= FabuddAdapter(requireContext(),it.data.data)
                binding.review.adapter= fabiada



            }else{
                Toast.makeText(context, it.msg, Toast.LENGTH_SHORT).show()
            }

        })


    }


}